package com.lemon.library.common;

import android.os.Bundle;
import android.support.annotation.Nullable;
import com.lemon.library.base.BaseActivity;
import com.lemon.library.mvp.BaseModel;
import com.lemon.library.mvp.BasePresenter;
import com.lemon.library.utils.ObjectGetByClassUtils;

/**
 * Created by Wisn on 2018/5/13 上午10:04.
 */
public abstract class CommonActivity<T extends BaseModel, E extends BasePresenter> extends BaseActivity {

    public T mModel;
    public E mPresenter;
    protected boolean bActive = false;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        if (mModel == null) mModel = ObjectGetByClassUtils.getClass(this, 0);
        if (mPresenter == null) mPresenter = ObjectGetByClassUtils.getClass(this, 1);
        if (mModel != null && mPresenter != null) {
            mPresenter.setMV(mModel, this);
        }
        super.onCreate(savedInstanceState);
        bActive = true;
    }


    @Override
    protected void onResume() {
        super.onResume();
    }


    @Override
    public void onDestroy() {
        super.onDestroy();
        if (mPresenter != null) mPresenter.onDestroy();
        bActive = false;
    }

}
